package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo4 {
    public static void main(String[] args) throws Exception {
        Person p = new Person();
        p.sayHello();


        Scanner scanner = new Scanner(System.in);
        System.out.println("说");
        String className = scanner.nextLine();
        System.out.println("说");
        String methodName = scanner.nextLine();



        Class cal = Class.forName(methodName);
        Object o = cal.newInstance();
        Method method = cal.getMethod(methodName);
        method.invoke(o);

    }
}
